package com.llkj.contractmanagement.contractmanagement.mine;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.llkj.contractmanagement.main.BaseFragment;
import com.llkj.contractmanagement.R;
import com.llkj.contractmanagement.contractmanagement.contract.FileListActivity;
import com.llkj.contractmanagement.contractmanagement.contract.SystemMessageActivity;
import com.llkj.contractmanagement.customview.RoundImageView;
import com.llkj.contractmanagement.model.UserInfoBean;
import com.llkj.contractmanagement.utils.ImageLoaderUtil;

import butterknife.Bind;

/**
 * author: dong.yj
 * created on: 2016/8/15 9:18
 * description:个人中心界面
 */
public class MineFragment extends BaseFragment implements View.OnClickListener {

    @Bind(R.id.rl_head)
    RelativeLayout rl_head;//头像
    @Bind(R.id.rl_message)
    RelativeLayout rl_message;//我的消息
    @Bind(R.id.rl_browsinghistory)
    RelativeLayout rl_browsinghistory;//浏览足迹
    @Bind(R.id.rl_collection)
    RelativeLayout rl_collection;//我的收藏
    @Bind(R.id.rl_setting)
    RelativeLayout rl_setting;//系统设置
    @Bind(R.id.rl_my_down)
    RelativeLayout rlMyDown;//我的下载
    @Bind(R.id.riv_head)
    RoundImageView riv_head;//头像
    @Bind(R.id.tv_mine_name)
    TextView tv_username;

    private UserInfoBean userInfoBean;

    @Override
    public int getContentViewLayout() {
        return R.layout.fragment_mine;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
    }

    private void init() {
        initData();
        setListener();
    }

    private void setListener() {
        rl_head.setOnClickListener(this);
        rl_message.setOnClickListener(this);
        rl_browsinghistory.setOnClickListener(this);
        rl_collection.setOnClickListener(this);
        rl_setting.setOnClickListener(this);
        rlMyDown.setOnClickListener(this);
    }

    private void initData() {
//        userInfoBean = UserInfoBean.getInstance();
//        ImageLoaderUtil.displayHeaderImage(userInfoBean.getLogo(),riv_head);
//        tv_username.setText(userInfoBean.getName());
    }

    @Override
    public void onResume() {
        super.onResume();
        userInfoBean = UserInfoBean.getInstance();
        ImageLoaderUtil.displayHeaderImage(userInfoBean.getLogo(),riv_head);
        tv_username.setText(userInfoBean.getName());
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case R.id.rl_head://头像
                intent = new Intent(ctx, UserInfoActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_message://我的消息
                intent = new Intent(ctx, SystemMessageActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_browsinghistory://浏览足迹
                intent = new Intent(ctx, BrowsingHistoryActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_collection://我的收藏
                intent = new Intent(ctx, MyCollectionActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_my_down://我的下载
                intent = new Intent(ctx, FileListActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_setting://系统设置
                intent = new Intent(ctx, SettingActivity.class);
                startActivity(intent);
                break;
            default:
                break;
        }
    }
}
